package com.vote.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.vote.dao.util.HibernateDao;
import com.vote.entity.PrizeSetting;
import com.vote.util.VoteConstants;

@Repository
public class PrizeSettingDao extends HibernateDao<PrizeSetting, Long> {
	
	private static Logger logger = LoggerFactory.getLogger(PrizeSettingDao.class);
	
	public List<PrizeSetting> listPrizeSettings(){
		return this.createQuery("from PrizeSetting ps where status=?", VoteConstants.COMMON_STATUS_ENABLE).list();
	}	
	
	/**
	 * 取最小级别将设置
	 * @return
	 */
	public PrizeSetting getMinPrizeSetting(){
		List<PrizeSetting> psLst= this.createQuery("from PrizeSetting ps where status=? order by prizeLevel", VoteConstants.COMMON_STATUS_ENABLE).setMaxResults(1).list();
		if(psLst!=null && psLst.size()>0){
			return psLst.get(0);
		}else{
			return null;
		}
	}
}